package com.jinken.controller;

import com.jinken.service.IPaymentService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {

    /**
     * @DubboReference
     * 1，标记Dubbo的服务引用，消费者贴上此注解，Dubbo服务在程序启动，就会将服务注入到当前这个消费者中
     * 2, Dubbo自动处理远程服务过程
     * 3，透明的远程服务调用，不需要关注细节。调用者直接调用即可
     */

    /**
     * 属性说明
     *  check = false,设置启动不检查服务提供者
     *  timeout = 2000 设置访问服务超时时间
     *  retries = 3 设置访问服务提供者失败重试次数
     *  version = "2.0.0" 选择服务版本
     *  cluster 集群选择策略
     *
     */
    @DubboReference(check = false,
            timeout = 2000,
            retries = 10,
            cluster = "failover",
            mock = "fail:return \"服务器繁忙，请稍后访问\"")
    private IPaymentService paymentService;

    @GetMapping("/getPayment")
    public String getPaymentStatus(){
        String result = paymentService.payment(12312321);
        return result;
    }
}
